/**
 * Created by hy1 on 2018/4/12.
 */
$().ready(function(){
	$("[data-href]").on("click", function (e) {
        e.stopPropagation();location.href=$(this).data("href");
    });
})

/*trade history order*/
//订单详情  Token_Trading_History_Order.html
function GetRequest() {
    var url = location.search; //获取url中"?"符后的字串
    var theRequest = new Object();
    if (url.indexOf("?") != -1) {
        var str = url.substr(1);
        strs = str.split("&");
        for(var i = 0; i < strs.length; i ++) {
            theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);
        }
    }
    return theRequest;
}
var url=GetRequest();

$().ready(function(){
        var code=url.order;
//var code="a4a443b1-8f44-45ae-8f61-57922e1bd90d";
        if(!code){return true;}
      //查询消耗的平台币
        $.get("/app/public/ssw",function(r){
            console.log("消耗平台币",r);
            if(r.code==0){
                var txt=r.charge+"ssw"
                $("#platCoin").html(txt)
            }
        })
        $.ajax({
            url:"/app/order/showorder",
            type:"get",
            data:{code:code},
            success:function(r){
                console.log("order detail",r);
                if(r.code==0){
                    var data=r.orderEntity;
                    $("#formAdd").html(data.targetadd);//目标地址
                    $("#toAdd").html(data.refundadd);//存入地址
                    $("#transAdd").html(data.transferadd);//发送地址
                    $("#orderCode").html(data.code);//订单编号
                    $("#Oreder1").html(data.from);//目标地址币种
                    $("#Oreder2").html(data.to);//存放地址币种
                    //二维码
                    //codeUrl
                    var qrcode = new QRCode("qrcode", {
                        text:data.transferadd,
                        width: 200,
                        height: 200,
                    });
                    if(data.orderstatus==1){//待转币
                        $(".Token_Two_clod_text .Tokne_Cold_cent").eq(0).find("img").attr("src","../../img/two_cold_yes.png");
                        $(".Token_Two_clod_text .Tokne_Cold_cent").eq(1).find("img").remove();
                        $(".Token_Two_clod_text .Tokne_Cold_cent").eq(2).find("img").remove();
                    }else if(data.orderstatus==2){//已收到
                        $(".Token_Two_clod_text .Tokne_Cold_cent").eq(0).find("img").attr("src","../../img/two_cold_yes.png");
                        $(".Token_Two_clod_text .Tokne_Cold_cent").eq(1).find("img").attr("src","../../img/two_cold_yes.png");
                        $(".Token_Two_clod_text .Tokne_Cold_cent").eq(2).find("img").remove();
                    }else if(data.orderstatus==3){//成功
                        var img="<img src='../../img/two_cold_yes.png' alt=''/>"
                        $(".Token_Two_clod_text .Tokne_Cold_cent").eq(0).find("img").attr("src","../../img/two_cold_yes.png");
                        $(".Token_Two_clod_text .Tokne_Cold_cent").eq(1).find("img").attr("src","../../img/two_cold_yes.png");
                        $(".Token_Two_clod_text .Tokne_Cold_cent").eq(2).find("img").attr("src","../../img/two_cold_yes.png");
                    }else if(data.orderstatus==4){//失败
                        var html="<li><span>当前进度</span><span><i></i>订单失败</span></li>"
                        $(".Token_Two_clod_text .Tokne_Cold_cent+.Tokne_Cold_cent").remove();
                        $(".Token_Two_clod_text .Tokne_Cold_cent").html(html);
                    }

                }else{
                    alert(r.msg);
                }

            }
        })
    })


